package com.mdl.mall.controller;

import com.mdl.mall.util.FileDownloadUtil;
import org.apache.http.HttpEntity;
import org.apache.http.HttpStatus;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.ibatis.reflection.ExceptionUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.util.UUID;

/**
 * @Desc
 * @Author madengling
 * @Time 2020/10/16 9:18
 */
@ApiIgnore
@Controller
@RequestMapping("user")
public class UserController {

    @RequestMapping(value = "/login1", method = RequestMethod.POST)
    public String login1(String username, String sex){
//        UserDto userDto = new UserDto();
//        userDto.setUsername(username);
//        userDto.setSex(sex);
//        userDto.setTelephone("13678807723");
        return "redirect:index";
    }

    @RequestMapping("/download")
    public void downloadFile(HttpServletResponse response) {
        String fileUrl = "http://recept.zjzwfw.gov.cn/oss//form/4ec73f42-9218-372c-b245-01eefb11d634.jpg";
//        String fileName = UUID.randomUUID().toString()+".jpg";
        FileDownloadUtil.DownloadFj(response,null,fileUrl);
    }
}
